//alert("测试文件")
var canvasWidth = 877;
var canvasHeight = 672;
var canvas = document.getElementById('canvas');
canvas.width = canvasWidth;
canvas.height = canvasHeight;
var context = canvas.getContext('2d');
var radius = 50;
var image = new Image();
image.src = 'images/pic.png';
image.onload = function() {
    initCanvas();
}

function initCanvas() {
    console.log('调用初始化画布方法');
    context.clearRect(0, 0, canvas.width, canvas.height);
    context.save();
    context.beginPath();
    var x = Math.random() * (canvas.width - 2 * radius) + radius;
    var y = Math.random() * (canvas.height - 2 * radius) + radius;
    console.log(x);
    console.log(y);
    context.arc(x, y, radius, 0, 2 * Math.PI, true);
    context.clip();
    context.drawImage(image, 0, 0);
    context.restore();
}

function reset() {
    console.log('reset');
    initCanvas();
}

function show() {
    console.log('show');
    radius = 2 * Math.max(canvas.width, canvas.height);
    console.log(radius);
    initCanvas();
}